#include "ChickenCase2.h"
#include "Map.h"

ChickenCase2::ChickenCase2(void)
	: mScreenPosition (2)
{
}

ChickenCase2::~ChickenCase2(void)
{
}

void ChickenCase2::Load()
{
	mSprite.Load("chickencase.png");
}

void ChickenCase2::Unload()
{
	mSprite.Unload();
}

void ChickenCase2::Update(float deltaTime)
{
	int numChickens = 6;

	const float kSpacing = 735.0f / (numChickens - 1);

	if(Input_IsKeyPressed(Keys::RIGHT))
	{
		if(mScreenPosition < numChickens)
		{
			mPosition.x += kSpacing;
			mScreenPosition++;
		}
	}
	else if(Input_IsKeyPressed(Keys::LEFT))
	{
		if(mScreenPosition > 1)
		{
			mPosition.x -= kSpacing;
			mScreenPosition--;
		}
	}
}
	
void ChickenCase2::Render(const SVector2& viewOffset)
{
	const int width = mSprite.GetWidth();
	const int height = mSprite.GetHeight();
	SVector2 offset(width * 0.5f, height * 0.5f);
	SVector2 renderPosition = mPosition - offset;
	mSprite.SetPosition(renderPosition);
	mSprite.Render();
}

SRect ChickenCase2::GetBoundingBox() const
{
	SRect boundingBox;
	boundingBox.min.x = mPosition.x - 64.0f;
	boundingBox.max.x = mPosition.x + 64.0f;
	return boundingBox;
}